package com.mr.sell.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.mr.sell.utils.ConstantEnum;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @ClassName: OrderMaster
 * @User MRui
 * @Description: TODO描述：订单
 * @date 2018.09.19 22:51
 */
@Data
@Entity
@DynamicUpdate
//@JsonInclude(JsonInclude.Include.NON_NULL)//局部将为null的字段不返回
public class OrderMaster {
    /*支付状态, 默认未支付0*/
    @Id
    private String orderId;
    /*买家名字*/
    private String buyerName;
    /*买家电话*/
    private String buyerPhone;
    /*买家地址*/
    private String buyerAddress;
    /*订单总金额*/
    private BigDecimal orderAmount;
    /*买家微信openid*/
    private String buyerOpenid;
    /*订单状态, 默认为新下单0*/
    private int orderStatus = ConstantEnum.ORDER_NEW.getCode();
    /*支付状态, 默认未支付0*/
    private int payStatus = ConstantEnum.PAY_WAIT.getCode();
    private Date createTime;
    private Date updateTime;
    /*订单详情,@Transient 将该属性略过数据库的识别，在与数据库对应的时候忽略掉*/
    @Transient//数据库映射忽略掉
    private List<OrderDetail> orderDetailList;

    /**
    * User (作者): MRui
    * TODO (描述)：类似于标签根据code转换成message(获取订单状态)
    * Data：2018.09.28 22:23
    */
    @JsonIgnore//转JSON时忽略掉
    public String getOrderStatusMessage(){
        String message = ConstantEnum.getConstantEnum(orderStatus);
        return message;
    }
    /**
     * User (作者): MRui
     * TODO (描述)：类似于标签根据code转换成message（获取支付状态）
     * Data：2018.09.28 22:23
     */
    @JsonIgnore//转JSON时忽略掉
    public String getPayStatusMessage(){
        String message = ConstantEnum.getConstantEnum(payStatus);
        return message;
    }
}
